package com.kingsoft.dc.khaos.extender.meta.model.auth;

import java.util.Map;

/**
 * Created by jing on 19/8/7.
 */
public class AuthDetailInfo {
    private String dbName;

    private String tableName;

    private Map<String, Object> privsResults;

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Map<String, Object> getPrivsResults() {
        return privsResults;
    }

    public void setPrivsResults(Map<String, Object> privsResults) {
        this.privsResults = privsResults;
    }

    public String formatDetailInfo() {
        StringBuffer sb = new StringBuffer();
        if (privsResults != null) {
            for (Map.Entry<String, Object> result: privsResults.entrySet()) {
                String priv = result.getKey();
                if (result.getValue() != null) {
                    boolean hasPriv = Boolean.valueOf(result.getValue().toString());
                    if (!hasPriv) {
                        sb.append(priv);
                    }
                }
                sb.append(",");
            }
        }
        return sb.toString();
    }
}
